
#ifndef BUFFER_H
#define BUFFER_H

#include <limits>

//Buffer class

class Buffer {
public:
	int height, width;
};


class DepthBuffer:public Buffer {
public:
	
	float** depthBuffer;

	DepthBuffer(int _width, int _height) {
		this->height = _height;
		this->width = _width;	
		depthBuffer = new float* [height];
		for (int i = 0; i < height; i++) {
			depthBuffer[i] = new float[width];
		}

		for (int i = 0; i < height; i++) {
			for (int j = 0; j < width; j++) {
				depthBuffer[i][j] = 1;
			}
		}
	}

	~DepthBuffer() {
		for (int i = 0; i < height; i++) {
			delete[] depthBuffer[i];
		}
	}





	float Clamp(float min, float max, float value)
	{
		if (value > max) return  max;
		if (value < min) return min;
		return value;
	}

	//texture sampling
	float Sample(float u, float v) {
		int x = Clamp(0, width - 1, v);
		int y = Clamp(0, height - 1, u);
		

		return depthBuffer[y][x];

	}


	
};







#endif // !BUFFER_H
